home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2001 September / PC-WELT 9-2001.ISO / software / hw / brennen / flask_src.exe / Resizer / VBitmap.h < prev   
Encoding:
C/C++ Source or Header  |  2000-05-06  |  4.2 KB  |  143 lines

  1. /* 
  2.  *  vbitmap.h   - Original code from Avery Lee's Virtual Dub
  3.  *
  4.  *    Copyright (C) Alberto Vigata - ultraflask@yahoo.com - January 2000
  5.  *
  6.  *  This file is part of FlasKMPEG, a free MPEG to MPEG/AVI converter
  7.  *    
  8.  *  FlasKMPEG is free software; you can redistribute it and/or modify
  9.  *  it under the terms of the GNU General Public License as published by
  10.  *  the Free Software Foundation; either version 2, or (at your option)
  11.  *  any later version.
  12.  *   
  13.  *  FlasKMPEG is distributed in the hope that it will be useful,
  14.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.  *  GNU General Public License for more details.
  17.  *   
  18.  *  You should have received a copy of the GNU General Public License
  19.  *  along with GNU Make; see the file COPYING.  If not, write to
  20.  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
  21.  *
  22.  */
  23.  
  24.  
  25.  
  26. #ifndef f_VIRTUALDUB_VBITMAP_H
  27. #define f_VIRTUALDUB_VBITMAP_H
  28.  
  29. #include <windows.h>
  30.  
  31. typedef unsigned long    Pixel;
  32. typedef unsigned long    Pixel32;
  33. typedef unsigned char    Pixel8;
  34. typedef long            PixCoord;
  35. typedef    long            PixDim;
  36. typedef    long            PixOffset;
  37.  
  38. #ifdef VDEXT_VIDEO_FILTER
  39. #define NOVTABLE __declspec(novtable)
  40. #else
  41. #define NOVTABLE
  42. #endif
  43.  
  44. class NOVTABLE VBitmap {
  45. public:
  46.     Pixel *            data;
  47.     Pixel *            palette;
  48.     int                depth;
  49.     PixCoord        w, h;
  50.     PixOffset        pitch;
  51.     PixOffset        modulo;
  52.     PixOffset        size;
  53.     PixOffset        offset;
  54.  
  55.     Pixel *Address() const {
  56.         return (Pixel *)(data + offset);
  57.     }
  58.  
  59.     Pixel *Address(PixCoord x, PixCoord y) const {
  60.         return Addressi(x, h-y-1);
  61.     }
  62.  
  63.     Pixel *Addressi(PixCoord x, PixCoord y) const {
  64.         return (Pixel *)((char *)data + y*pitch + x*(depth>>3));
  65.     }
  66.  
  67.     Pixel *Address32(PixCoord x, PixCoord y) const {
  68.         return Address32i(x, h-y-1);
  69.     }
  70.  
  71.     Pixel *Address32i(PixCoord x, PixCoord y) const {
  72.         return (Pixel *)((char *)data + y*pitch + x*sizeof(Pixel));
  73.     }
  74.  
  75.     PixOffset PitchAlign4() {
  76.         return ((w * depth + 31)/32)*4;
  77.     }
  78.  
  79.     PixOffset PitchAlign8() {
  80.         return ((w * depth + 63)/64)*8;
  81.     }
  82.  
  83.     PixOffset Modulo() {
  84.         return pitch - (w*depth+7)/8;
  85.     }
  86.  
  87.     PixOffset Size() {
  88.         return pitch*h;
  89.     }
  90.  
  91.     //////
  92.  
  93.     VBitmap() throw() {
  94. #ifdef VDEXT_VIDEO_FILTER
  95.         init();
  96. #endif
  97.     }
  98.     VBitmap(void *data, PixDim w, PixDim h, int depth) throw();
  99.     VBitmap(void *data, BITMAPINFOHEADER *) throw();
  100.  
  101. #ifdef VDEXT_VIDEO_FILTER
  102.     void init() throw() { *(void **)this = g_vtbls.pvtblVBitmap; }
  103. #endif
  104.  
  105.     virtual VBitmap& init(void *data, PixDim w, PixDim h, int depth) throw();
  106.     virtual VBitmap& init(void *data, BITMAPINFOHEADER *) throw();
  107.  
  108.     virtual void MakeBitmapHeader(BITMAPINFOHEADER *bih) const throw();
  109.  
  110.     virtual void AlignTo4() throw();
  111.     virtual void AlignTo8() throw();
  112.  
  113.     virtual void BitBlt(PixCoord x2, PixCoord y2, const VBitmap *src, PixCoord x1, PixCoord y1, PixDim dx, PixDim dy) const throw();
  114.     virtual void BitBltDither(PixCoord x2, PixCoord y2, const VBitmap *src, PixDim x1, PixDim y1, PixDim dx, PixDim dy, bool to565) const throw();
  115.     virtual void BitBlt565(PixCoord x2, PixCoord y2, const VBitmap *src, PixDim x1, PixDim y1, PixDim dx, PixDim dy) const throw();
  116.  
  117.     virtual bool BitBltXlat1(PixCoord x2, PixCoord y2, const VBitmap *src, PixCoord x1, PixCoord y1, PixDim dx, PixDim dy, const Pixel8 *tbl) const throw();
  118.     virtual bool BitBltXlat3(PixCoord x2, PixCoord y2, const VBitmap *src, PixCoord x1, PixCoord y1, PixDim dx, PixDim dy, const Pixel32 *tbl) const throw();
  119.  
  120.     virtual bool StretchBltNearestFast(PixCoord x1, PixCoord y1, PixDim dx, PixDim dy, const VBitmap *src, double x2, double y2, double dx1, double dy1) const throw();
  121.  
  122.     virtual bool StretchBltBilinearFast(PixCoord x1, PixCoord y1, PixDim dx, PixDim dy, const VBitmap *src, double x2, double y2, double dx1, double dy1) const throw();
  123.  
  124.     virtual bool RectFill(PixCoord x1, PixCoord y1, PixDim dx, PixDim dy, Pixel32 c) const throw();
  125.  
  126.     enum {
  127.         HISTO_LUMA,
  128.         HISTO_GRAY,
  129.         HISTO_RED,
  130.         HISTO_GREEN,
  131.         HISTO_BLUE,
  132.     };
  133.  
  134.  
  135.  
  136. private:
  137.     bool dualrectclip(PixCoord& x2, PixCoord& y2, const VBitmap *src, PixCoord& x1, PixCoord& y1, PixDim& dx, PixDim& dy) const throw();
  138. };
  139.  
  140. #undef NOVTABLE
  141.  
  142. #endif
  143.